
local rpc = require 'rpc'
local interface = require 'interface'

--Implement Methods
local sum=0
methods = {
  foo = function ( a, b, c )
          print('foo',a + b + c)
          return a + b + c
        end,
  boo = function ()
          sum = sum + 1
          print('boo',sum)
        end,
  bar = function ( s )
          print('bar',#s)
          return 2.2
        end
}

methods2 = {
  foo = function ()
        end,
  boo = function ()
        end,
  bar = function ( s )
          print('bar',#s)
          local t = loadstring(s)()
          return t[1]
        end
}

--Set the server
rpc.setServIp( "*" )
local serv1 = rpc.createServant( methods, interface )
local serv2 = rpc.createServant( methods2, interface )

print( 'serv1 ip' .. serv1.ip .. ' port=' .. serv1.port )
print( 'serv2 ip' .. serv2.ip .. ' port=' .. serv2.port )

rpc.waitIncomming() 
